*** Replication code for the creation of the dataset and the main analyses reported in
*** Multiple Measurements, Elusive Agreement, and Unstable Outcomes in the Study of Regime Change
*** Hans Lueders and Ellen Lust
*** October 2017


*** load data
use "LuedersLust2017_regimetypedata.dta", clear


******************************************************************************************
**********************1. Preparation of the regime change dataset*************************
******************************************************************************************

*** (1) Coding regime type ***
*----------------------------*
* Boix et al. 2013
gen democracy_boix = boix_democracy

* Cheibub et al. 2010
gen democracy_cgv = cgv_democracy

* Freedom House (FIW: free)
gen democracy_fh_free_status = .
replace democracy_fh_free_status = 1 if fh_status ==1
replace democracy_fh_free_status = 0 if fh_status > 1 & fh_status != .

* Geddes et al. 2014
gen democracy_gwf = .
replace democracy_gwf = 1 if gwf_regime == 1
replace democracy_gwf = 0 if gwf_regime > 1 & gwf_regime != .

* Magaloni et al. 2013
gen democracy_magaloni = .
replace democracy_magaloni = magaloni_demo_nr

* Polity IV (AN=AUT)
gen democracy_polity = .
replace democracy_polity = 1 if p_polity2 >= 6 & p_polity2 != .
replace democracy_polity = 0 if p_polity2 <6

* Reich 2002
gen democracy_reich = .
replace democracy_reich = 1 if reich_regime_notransition==1
replace democracy_reich = 1 if reich_regime_notransition==2
replace democracy_reich = 0 if reich_regime_notransition==0

* Skaaning et al. 2015
gen democracy_lexical = .
replace democracy_lexical = 1 if liedlexical_index >= 4 & liedlexical_index != .
replace democracy_lexical = 0 if liedlexical_index < 4
label variable democracy_lexical "Democratic Regime Dummy (Skaaning et al. 2015)"

* Svolik 2012
bysort ccode_cow: gen svolik_regime_lead = svolik_regime[_n+1]	// coded as of January 1 of each year
gen democracy_svolik = .
replace democracy_svolik = 1 if svolik_regime_lead == "democracy"
replace democracy_svolik = 0 if svolik_regime_lead == "dictatorship"

* Ulfelder 2012
gen democracy_ulfelder = .
replace democracy_ulfelder = 1 if ulfelder_regime == 1
replace democracy_ulfelder = 0 if ulfelder_regime == 0

* Wahman et al. 2013
gen democracy_htw = .
replace democracy_htw = 1 if htw_regime1ny == 100
replace democracy_htw = 0 if htw_regime1ny <100



*** (2) Coding rupture ***
*-------------------------*
*** lagging all variables
sort ccode_cow year

foreach var in democracy_boix democracy_cgv democracy_fh_free_status democracy_gwf democracy_magaloni ///
   democracy_polity democracy_reich democracy_svolik democracy_ulfelder democracy_htw {
   by ccode_cow: gen `var'_lag = `var'[_n-1]
}


*** coding democratic breakdown
foreach var in boix cgv fh_free_status gwf magaloni ///
   polity reich svolik ulfelder htw {
   gen breakdown_`var' = .
   replace breakdown_`var' = 1 if democracy_`var'_lag == 1 & democracy_`var' == 0
   replace breakdown_`var' = 0 if democracy_`var'_lag == 1 & democracy_`var' == 1
   replace breakdown_`var' = 0 if democracy_`var'_lag == 0 & democracy_`var' == 0
   replace breakdown_`var' = 0 if democracy_`var'_lag == 0 & democracy_`var' == 1
}

gen breakdown_bnr = bnr_event

*** coding democratic transition
foreach var in boix cgv fh_free_status gwf magaloni ///
   polity reich svolik ulfelder htw {
   gen transition_`var' = .
   replace transition_`var' = 1 if democracy_`var'_lag == 0 & democracy_`var' == 1
   replace transition_`var' = 0 if democracy_`var'_lag == 0 & democracy_`var' == 0
   replace transition_`var' = 0 if democracy_`var'_lag == 1 & democracy_`var' == 1
   replace transition_`var' = 0 if democracy_`var'_lag == 1 & democracy_`var' == 0
}


*** (3) Coding reform ***
*-----------------------*
*** lagging variables by one year
sort ccode_cow year
foreach var in fh_score p_polity2 liedlexical_index vdem_v2x_polyarchy{
	by ccode_cow: gen `var'_lag = `var'[_n-1]
}

by ccode_cow: gen htw_ifhpol_lag = htw_ifhpol[_n-1]


*** coding democratic backsliding
* Freedom House (FIW, any change)
gen backslide_fh_score = .
replace backslide_fh_score = 1 if fh_score_lag < fh_score & fh_score_lag != . & fh_score != .
replace backslide_fh_score = 0 if fh_score_lag >= fh_score & fh_score_lag !=. & fh_score != .

* Polity IV (any change)
gen backslide_polity = .
replace backslide_polity = 1 if p_polity2_lag > p_polity2 & p_polity2_lag !=. & p_polity2 != .
replace backslide_polity = 0 if p_polity2_lag <= p_polity2 & p_polity2_lag !=. & p_polity2 != .

* Skaaning et al. 2015
gen backslide_lexical = .
replace backslide_lexical = 1 if liedlexical_index_lag > liedlexical_index & liedlexical_index_lag != . & liedlexical_index !=.
replace backslide_lexical = 0 if liedlexical_index_lag <= liedlexical_index & liedlexical_index_lag !=. & liedlexical_index !=.

* V-Dem: Electoral Democracy
gen vdem_change_electoral = sqrt((vdem_v2x_polyarchy_lag - vdem_v2x_polyarchy)^2)
summarize vdem_change_electoral
gen backslide_vdem_elec = .
replace backslide_vdem_elec = 1 if vdem_v2x_polyarchy_lag - vdem_v2x_polyarchy >=r(sd) & vdem_v2x_polyarchy_lag !=. & vdem_v2x_polyarchy !=.
replace backslide_vdem_elec = 0 if vdem_v2x_polyarchy_lag - vdem_v2x_polyarchy <r(sd) & vdem_v2x_polyarchy_lag !=. & vdem_v2x_polyarchy !=.

* Wahman et al. 2013 (any change)
gen backslide_htw = .
replace backslide_htw = 1 if htw_ifhpol_lag > htw_ifhpol & htw_ifhpol_lag !=. & htw_ifhpol != .
replace backslide_htw = 0 if htw_ifhpol_lag <= htw_ifhpol & htw_ifhpol_lag !=. & htw_ifhpol != .


*** coding liberalization
* Freedom House (FIW, any change)
gen liberal_fh_score = .
replace liberal_fh_score = 1 if fh_score_lag > fh_score & fh_score_lag != . & fh_score != .
replace liberal_fh_score = 0 if fh_score_lag <= fh_score & fh_score_lag !=. & fh_score != .

* Polity IV (any change)
gen liberal_polity = .
replace liberal_polity = 1 if p_polity2_lag < p_polity2 & p_polity2_lag !=. & p_polity2 != .
replace liberal_polity = 0 if p_polity2_lag >= p_polity2 & p_polity2_lag !=. & p_polity2 != .

* Skaaning et al. 2015
gen liberal_lexical = .
replace liberal_lexical = 0 if liedlexical_index_lag >= liedlexical_index & liedlexical_index_lag != . & liedlexical_index !=.
replace liberal_lexical = 1 if liedlexical_index_lag < liedlexical_index & liedlexical_index_lag !=. & liedlexical_index !=.

* V-Dem: Electoral Democracy
summarize vdem_change_electoral
gen liberal_vdem_elec = .
replace liberal_vdem_elec = 1 if vdem_v2x_polyarchy_lag - vdem_v2x_polyarchy <=-r(sd) & vdem_v2x_polyarchy_lag !=. & vdem_v2x_polyarchy !=.
replace liberal_vdem_elec = 0 if vdem_v2x_polyarchy_lag - vdem_v2x_polyarchy >-r(sd) & vdem_v2x_polyarchy_lag !=. & vdem_v2x_polyarchy !=.

* Wahman et al. 2013 (any change)
gen liberal_htw = .
replace liberal_htw = 1 if htw_ifhpol_lag < htw_ifhpol & htw_ifhpol_lag !=. & htw_ifhpol != .
replace liberal_htw = 0 if htw_ifhpol_lag >= htw_ifhpol & htw_ifhpol_lag !=. & htw_ifhpol != .



*** (4) Coding agreement of the rupture measures ***
*--------------------------------------------------*
*** Dummy indicator: data available 
foreach var in bnr boix cgv fh_free_status gwf magaloni ///
   polity reich svolik ulfelder htw {
   gen available_`var' = 0
   replace available_`var' = 1 if breakdown_`var' !=.
}

*** Sum up number of indicators available
* breakdown
gen available_break = available_bnr + available_boix + available_cgv + available_fh + available_gwf + available_htw + ///
   available_magaloni + available_polity + available_reich + available_ulfelder + available_svolik

* transition
gen available_trans = available_boix + available_cgv + available_fh + available_gwf + available_htw + ///
   available_magaloni + available_polity + available_reich + available_ulfelder + available_svolik

* note: there are a couple of cases for which htw_ifpol is available, but democracy_htw is not. Need to be taken into account when coding the availability measures:
replace available_trans = available_trans + 1 if htw_ifhpol_lag !=. & democracy_htw_lag == .


*** Sum up all indicators that code breakdown/transition in each year
* breakdown
egen sum_break = rowtotal(breakdown_bnr breakdown_boix breakdown_cgv breakdown_fh_free_status breakdown_gwf ///
   breakdown_htw breakdown_magaloni breakdown_polity breakdown_reich breakdown_ulfelder breakdown_svolik) if available_break >0 & available_break != .

* transition
egen sum_trans = rowtotal(transition_boix transition_cgv transition_fh_free_status transition_gwf ///
   transition_htw transition_magaloni transition_polity transition_reich transition_ulfelder transition_svolik) if available_trans >0 & available_trans != .


*** coding agreement
* breakdown
gen agreement_break = sum_break / available_break if available_break >0 & available_break != .

* transition
gen agreement_trans = sum_trans / available_trans if available_trans >0 & available_trans != .



*** (4) Coding agreement of the reform measures ***
*-------------------------------------------------*

*** Create dummy variable: Indicator available
* It seems that for some country-years, htw_ifhpol is available, while htw_regime1ny is not available. Hence, we need to code a second availability measure:
gen available_htw_backslide = 0
replace available_htw_backslide = 1 if htw_ifhpol!=. & htw_ifhpol_lag !=. 

foreach var in lexical vdem {
	gen available_`var' = 0
	replace available_`var' = 1 if backslide_`var' != .
}


*** Sum up number of indicators available
* backsliding
gen available_back = available_fh + available_htw_backslide + available_polity + available_lexical + available_vdem

* transtion
gen available_liberal = available_fh + available_htw_backslide + available_polity + available_lexical + available_vdem


*** Sum up all indicators that code backsliding/liberalization in each year
* backsliding
egen sum_back = rowtotal(backslide_fh_score backslide_polity backslide_htw backslide_lexical backslide_vdem_elec) if available_back >0 & available_back != .

* liberalization
egen sum_liberal = rowtotal(liberal_fh_score liberal_polity liberal_htw liberal_lexical liberal_vdem_elec) if available_liberal >0 & available_liberal != .


*** coding agreement
* backsliding
gen agreement_back = sum_back / available_back if available_back >0 & available_back != .

* liberalization
gen agreement_liberal = sum_liberal / available_liberal if available_liberal >0 & available_liberal != .



*** (5) Coding agreement for breakdown & backsliding, and transition & liberalization ***
*---------------------------------------------------------------------------------------*
*** breakdown & backsliding
* sum of available measures
gen available_backbreak = available_back + available_break

* sum of instances of regime change
gen sum_backbreak = sum_back + sum_break if available_back >0 & available_back !=. & available_break >0 & available_break !=.

* agreement
gen agreement_backbreak = sum_backbreak / available_backbreak

*** transition * liberalization
* sum of available measures
gen available_libtrans = available_liberal + available_trans

* sum of instances of regime change
gen sum_libtrans = sum_liberal + sum_trans if available_liberal >0 & available_liberal !=. & available_trans >0 & available_trans !=.

* agreement
gen agreement_libtrans = sum_libtrans / available_libtrans




*** (6) Coding three-year agreement ***
*-------------------------------------*

*** Step one: Create three-year moving averages of all variables of interest
* define data structure
sort ccode_cow year
tsset ccode_cow year

* breakdown
foreach var in bnr boix cgv fh_free_status gwf magaloni ///
   polity reich svolik ulfelder htw{
   tssmooth ma break_`var'_3yrs = breakdown_`var' if breakdown_`var' != ., window (1 1 1)
}

* transition
foreach var in boix cgv fh_free_status gwf magaloni ///
   polity reich svolik ulfelder htw{
   tssmooth ma trans_`var'_3yrs = transition_`var' if transition_`var' != ., window (1 1 1)
}

* backsliding & liberalization
foreach var in fh_score polity lexical vdem_elec htw{
	tssmooth ma back_`var'_3yrs = backslide_`var' if backslide_`var' !=., window (1 1 1)
	tssmooth ma lib_`var'_3yrs = liberal_`var' if liberal_`var' !=., window (1 1 1)
}



*** Step Two: Replace the three-year moving averages s.t. they are either 0 or 1   
* breakdown
foreach var in bnr boix cgv fh_free_status gwf magaloni ///
   polity reich svolik ulfelder htw{
   replace break_`var'_3yrs = 1 if break_`var'_3yrs >0 & break_`var'_3yrs != .
}

* transition
foreach var in boix cgv fh_free_status gwf magaloni ///
   polity reich svolik ulfelder htw{
   replace trans_`var'_3yrs = 1 if trans_`var'_3yrs >0 & trans_`var'_3yrs != .
}
   
* backsliding & liberalization
foreach var in fh_score polity lexical vdem_elec htw{
   replace back_`var'_3yrs = 1 if back_`var'_3yrs >0 & back_`var'_3yrs != .
   replace lib_`var'_3yrs = 1 if lib_`var'_3yrs >0 & lib_`var'_3yrs != .
}   
   
   

*** Step Three: Generate availability measure: = 1 if the three-year moving average is available 
* breakdown / transition
foreach var in bnr boix cgv fh_free_status gwf magaloni ///
   polity reich svolik ulfelder htw {
   gen available_`var'_3yrs = 0
   replace available_`var'_3yrs = 1 if break_`var'_3yrs !=.
}
   
* backsliding / liberalization
gen available_fh_3yrs = 0
replace available_fh_3yrs = 1 if back_fh_score != .

foreach var in lexical vdem_elec{
   gen available_`var'_3yrs = 0
   replace available_`var'_3yrs = 1 if back_`var'_3yrs != .
}

gen available_htw_backslide_3yrs = 0
replace available_htw_backslide_3yrs = 1 if back_htw_3yrs != .



*** Step Four: Coding of availability measure for three-year period
* Breakdown
gen available_break_3yrs = available_bnr_3yrs + available_boix_3yrs + available_cgv_3yrs + available_fh_3yrs ///
   + available_gwf_3yrs + available_htw_3yrs + available_magaloni_3yrs + available_polity_3yrs + available_reich_3yrs ///
   + available_ulfelder_3yrs + available_svolik_3yrs

* Backsliding
gen available_back_3yrs = available_polity_3yrs + available_fh_3yrs + available_htw_backslide_3yrs + available_lexical_3yrs + available_vdem_elec_3yrs

* Backsliding & Breakdown
gen available_backbreak_3yrs = available_back_3yrs + available_break_3yrs

* Transition
gen available_trans_3yrs = available_boix_3yrs + available_cgv_3yrs + available_fh_3yrs  ///
   + available_gwf_3yrs + available_htw_3yrs + available_magaloni_3yrs + available_polity_3yrs + available_reich_3yrs ///
   + available_ulfelder_3yrs + available_svolik_3yrs
   
* Liberalization   
gen available_lib_3yrs = available_polity_3yrs + available_fh_3yrs + available_htw_backslide_3yrs + available_lexical_3yrs + available_vdem_elec_3yrs

* Liberalization & Transition
gen available_libtrans_3yrs = available_lib_3yrs + available_trans_3yrs

   
*** Step Five: Sum of all measures that code event of interest   
* breakdown
egen sum_break_3yrs = rowtotal(break_bnr_3yrs break_boix_3yrs break_cgv_3yrs break_fh_free_status_3yrs ///
   break_gwf_3yrs break_htw_3yrs break_magaloni_3yrs break_polity_3yrs break_reich_3yrs break_ulfelder_3yrs break_svolik_3yrs) ///
   if available_break_3yrs > 0 & available_break_3yrs != .

* backsliding
egen sum_back_3yrs = rowtotal(back_fh_score_3yrs back_polity_3yrs back_htw_3yrs back_lexical_3yrs back_vdem_elec_3yrs) if available_back_3yrs >0 & available_back_3yrs != .

* breakdown & backsliding
gen sum_backbreak_3yrs = sum_back_3yrs + sum_break_3yrs ///
   if available_back_3yrs >0 & available_back_3yrs !=. & available_break_3yrs >0 & available_break_3yrs !=.

* transition
egen sum_trans_3yrs = rowtotal(trans_boix_3yrs trans_cgv_3yrs trans_fh_free_status_3yrs trans_gwf_3yrs ///
   trans_htw_3yrs trans_magaloni_3yrs trans_polity_3yrs trans_reich_3yrs trans_ulfelder_3yrs trans_svolik_3yrs) ///
   if available_trans_3yrs >0 & available_trans_3yrs != .

* liberalization
egen sum_lib_3yrs = rowtotal(lib_fh_score_3yrs lib_polity_3yrs lib_htw_3yrs lib_lexical_3yrs lib_vdem_elec_3yrs) if available_lib_3yrs >0 & available_lib_3yrs != .

* transition & liberalization
gen sum_libtrans_3yrs = sum_lib_3yrs + sum_trans_3yrs if available_lib_3yrs >0 & available_lib_3yrs !=. & ///
   available_trans_3yrs >0 & available_trans_3yrs !=.
   
   
*** Step Six: Generate the agreement measures   
* breakdown
gen agreement_break_3yrs = sum_break_3yrs / available_break_3yrs if available_break_3yrs >0 & available_break_3yrs !=.

* backsliding
gen agreement_back_3yrs = sum_back_3yrs / available_back_3yrs if available_back_3yrs >0 & available_back_3yrs !=.

* breakdown & backsliding
gen agreement_backbreak_3yrs = sum_backbreak_3yrs / available_backbreak_3yrs if available_backbreak_3yrs >0 & available_backbreak_3yrs !=.

* transition
gen agreement_trans_3yrs = sum_trans_3yrs / available_trans_3yrs if available_trans_3yrs >0 & available_trans_3yrs !=.

* liberalization
gen agreement_lib_3yrs = sum_lib_3yrs / available_lib_3yrs if available_lib_3yrs >0 & available_lib_3yrs !=.

* transition & liberalization   
gen agreement_libtrans_3yrs = sum_libtrans_3yrs / available_libtrans_3yrs if available_libtrans_3yrs >0 & available_libtrans_3yrs !=.

   
   
*** (7) Coding variables for regression analyis ***
*-------------------------------------------------*   
*** log transformation of measures of availability
gen available_back_ln = ln(available_back + 1)
gen available_break_ln = ln(available_break + 1)
gen available_liberal_ln = ln(available_liberal + 1)
gen available_trans_ln = ln(available_trans + 1)

gen available_backbreak_ln = ln(available_backbreak + 1)
gen available_libtrans_ln = ln(available_libtrans + 1)

gen available_back_3yrs_ln = ln(available_back_3yrs + 1)
gen available_break_3yrs_ln = ln(available_break_3yrs + 1)
gen available_lib_3yrs_ln = ln(available_lib_3yrs + 1)
gen available_trans_3yrs_ln = ln(available_trans_3yrs + 1)

gen available_backbreak_3yrs_ln = ln(available_backbreak_3yrs + 1)
gen available_libtrans_3yrs_ln = ln(available_libtrans_3yrs + 1)
   
   
*** log transformation of GDP, GDP p.c., and population   
gen wdi_gdp_const_ln = ln(wdi_gdp_const)
gen wdi_gdppc_ln = ln(wdi_gdppc)
gen wdi_population_ln = ln(wdi_population)   
   
   
*** coup data = code non-instances of coups
replace coup = 0 if coup != 1 & year >=1950 & year <=2010   
   
   
*** lagging GATT membership by one year (Ulfelder)
sort ccode_cow year
by ccode_cow: gen ulfelder_gatt_lag = ulfelder_gatt[_n-1]
   
   
*** aid per capita
gen wdi_aid_pc = wdi_aid_all_constant / wdi_population
gen wdi_aid_pc_ln = ln(wdi_aid_pc)

   
*** three-year averages, finishing in the year before the event of interest
tsset ccode_cow year
tssmooth ma wdi_population_ln_avg3 = wdi_population_ln, window(3 0 0)
tssmooth ma wdi_gdppc_ln_avg3 = wdi_gdppc_ln, window(3 0 0)
tssmooth ma wdi_gdp_const_ln_avg3 = wdi_gdp_const_ln, window(3 0 0)
tssmooth ma wdi_trade_avg3 = wdi_trade, window(3 0 0)
tssmooth ma wdi_aid_pc_ln_avg3 = wdi_aid_pc_ln, window(3 0 0)
   
  



******************************************************************************************
**********************2. Analyses reported in the paper***********************************
******************************************************************************************

*** Table 1: Indicators of regime change
** post-WWII
* toward democracy
tab transition_boix if year>1945
tab transition_cgv if year>1945
tab transition_fh_free_status if year>1945
tab transition_gwf if year>1945
tab transition_magaloni if year>1945
tab transition_polity if year>1945
tab transition_reich if year>1945
tab transition_svolik if year>1945
tab transition_ulfelder  if year>1945
tab transition_htw if year>1945

tab liberal_fh_score if year>1945
tab liberal_polity if year>1945
tab liberal_lexical if year>1945
tab liberal_vdem_elec if year>1945
tab liberal_htw if year>1945

* toward autocracy
tab breakdown_bnr if year>1945
tab breakdown_boix if year>1945
tab breakdown_cgv if year>1945
tab breakdown_fh_free_status if year>1945
tab breakdown_gwf if year>1945
tab breakdown_magaloni if year>1945
tab breakdown_polity if year>1945
tab breakdown_reich if year>1945
tab breakdown_svolik if year>1945
tab breakdown_ulfelder if year>1945
tab breakdown_htw if year>1945

tab backslide_fh_score if year>1945
tab backslide_polity if year>1945
tab backslide_lexical if year>1945
tab backslide_vdem_elec if year>1945
tab backslide_htw if year>1945


*** Table 2: Agreement between regime change indicators (same as Table A11 in Appendix III)
* breakdown
xtset ccode_cow year
eststo clear
eststo: xtreg agreement_break coup nelda_election wdi_population_ln_avg3 wdi_gdppc_ln_avg3 wdi_gdp_const_ln_avg3 ///
   wdi_trade_avg3 wdi_aid_pc_ln_avg3 ulfelder_gatt_lag  i.year ///
   available_break_ln if agreement_break >0, robust cluster(ccode_cow) fe 
   
* backsliding  
eststo: xtreg agreement_back coup nelda_election wdi_population_ln_avg3 wdi_gdppc_ln_avg3 wdi_gdp_const_ln_avg3 ///
   wdi_trade_avg3 wdi_aid_pc_ln_avg3 ulfelder_gatt_lag  i.year ///
   available_back_ln if agreement_back >0, robust cluster(ccode_cow) fe
     
* backsliding and breakdown   
eststo: xtreg agreement_backbreak coup nelda_election wdi_population_ln_avg3 wdi_gdppc_ln_avg3 wdi_gdp_const_ln_avg3 ///
   wdi_trade_avg3 wdi_aid_pc_ln_avg3 ulfelder_gatt_lag  i.year ///
   available_backbreak_ln if agreement_backbreak >0, robust cluster(ccode_cow) fe
   

* transition
eststo: xtreg agreement_trans coup nelda_election wdi_population_ln_avg3 wdi_gdppc_ln_avg3 wdi_gdp_const_ln_avg3 ///
   wdi_trade_avg3 wdi_aid_pc_ln_avg3 ulfelder_gatt_lag ///
   available_trans_ln i.year if agreement_trans >0, robust cluster(ccode_cow) fe 
   
* liberalization  
eststo: xtreg agreement_liberal coup nelda_election wdi_population_ln_avg3 wdi_gdppc_ln_avg3 wdi_gdp_const_ln_avg3 ///
   wdi_trade_avg3 wdi_aid_pc_ln_avg3 ulfelder_gatt_lag ///
   available_liberal_ln i.year if agreement_liberal >0, robust cluster(ccode_cow) fe 
     
* liberalization and transition   
eststo: xtreg agreement_libtrans coup nelda_election wdi_population_ln_avg3 wdi_gdppc_ln_avg3 wdi_gdp_const_ln_avg3 ///
   wdi_trade_avg3 wdi_aid_pc_ln_avg3 ulfelder_gatt_lag ///
   available_libtrans_ln i.year if agreement_libtrans >0, robust cluster(ccode_cow) fe 
   
* output   
esttab, star(* 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(2))) stats(N r2_a, fmt(0 3) label("N" "Adj. R2")) legend label ///
   keep(coup nelda_election wdi_population_ln_avg3 wdi_gdppc_ln_avg3 wdi_gdp_const_ln_avg3 ///
   wdi_trade_avg3 wdi_aid_pc_ln_avg3 ulfelder_gatt_lag available_break_ln available_back_ln available_backbreak_ln ///
   available_trans_ln available_liberal_ln available_libtrans_ln)
                         

   
*** Table 3: Robustness checks
* see separate STATA do-files


******************************************************************************************
**********************3. Appendix I: Computing combinations of Freedom House and Polity IV
******************************************************************************************

*** see separate R code file



******************************************************************************************
**********************4. Appendix III: Additional Tables**********************************
******************************************************************************************


*** Table A4: Indicators of Regime Change and Number of Regime Change Events
** full period
* transition
tab transition_boix
tab transition_cgv
tab transition_fh_free_status
tab transition_gwf
tab transition_magaloni
tab transition_polity
tab transition_reich
tab transition_svolik
tab transition_ulfelder 
tab transition_htw

* liberalization
tab liberal_fh_score
tab liberal_polity
tab liberal_lexical
tab liberal_vdem_elec
tab liberal_htw

* breakdown
tab breakdown_bnr 
tab breakdown_boix 
tab breakdown_cgv
tab breakdown_fh_free_status
tab breakdown_gwf
tab breakdown_magaloni
tab breakdown_polity
tab breakdown_reich
tab breakdown_svolik
tab breakdown_ulfelder
tab breakdown_htw

* backsliding
tab backslide_fh_score 
tab backslide_polity
tab backslide_lexical
tab backslide_vdem_elec
tab backslide_htw


** post-WWII
* transition
tab transition_boix if year>1945
tab transition_cgv if year>1945
tab transition_fh_free_status if year>1945
tab transition_gwf if year>1945
tab transition_magaloni if year>1945
tab transition_polity if year>1945
tab transition_reich if year>1945
tab transition_svolik if year>1945
tab transition_ulfelder  if year>1945
tab transition_htw if year>1945

* liberalization
tab liberal_fh_score if year>1945
tab liberal_polity if year>1945
tab liberal_lexical if year>1945
tab liberal_vdem_elec if year>1945
tab liberal_htw if year>1945

* breakdown
tab breakdown_bnr if year>1945
tab breakdown_boix if year>1945
tab breakdown_cgv if year>1945
tab breakdown_fh_free_status if year>1945
tab breakdown_gwf if year>1945
tab breakdown_magaloni if year>1945
tab breakdown_polity if year>1945
tab breakdown_reich if year>1945
tab breakdown_svolik if year>1945
tab breakdown_ulfelder if year>1945
tab breakdown_htw if year>1945

* backsliding
tab backslide_fh_score if year>1945
tab backslide_polity if year>1945
tab backslide_lexical if year>1945
tab backslide_vdem_elec if year>1945
tab backslide_htw if year>1945



*** Table A5: Pairwise correlation coefficients between indicators of regime type
pwcorr democracy_boix democracy_cgv democracy_fh_free_status democracy_gwf democracy_magaloni democracy_polity ///
   democracy_reich democracy_lexical democracy_svolik democracy_ulfelder democracy_htw ///
   fh_score p_polity2 vdem_v2x_polyarchy htw_ifhpol

   
*** Table A6: Pairwise correlation between measures of Breakdown
pwcorr breakdown_bnr breakdown_boix breakdown_cgv breakdown_fh_free_status breakdown_gwf breakdown_magaloni ///
   breakdown_polity breakdown_reich breakdown_svolik breakdown_ulfelder breakdown_htw

   
*** Table A7: Pairwise correlation between measures of Backsliding
pwcorr backslide_fh_score backslide_polity backslide_lexical backslide_vdem_elec backslide_htw


*** Table A8: Pairwise correlation between measures of Transition
pwcorr transition_boix transition_cgv transition_fh_free_status transition_gwf transition_magaloni transition_polity ///
   transition_reich transition_svolik transition_ulfelder transition_htw

   
*** Table A9: Pairwise correlation between measures of Liberalization
pwcorr liberal_fh_score liberal_polity liberal_lexical liberal_vdem_elec liberal_htw


*** Table A12: Agreement between regime chnage indicators, three-year period
* breakdown
eststo clear
eststo: xtreg agreement_break_3yrs coup nelda_election wdi_population_ln_avg3 wdi_gdppc_ln_avg3 wdi_gdp_const_ln_avg3 ///
   wdi_trade_avg3 wdi_aid_pc_ln_avg3 ulfelder_gatt_lag ///
   available_break_3yrs_ln i.year if agreement_break_3yrs >0, robust cluster(ccode_cow) fe 
   
* backsliding  
eststo: xtreg agreement_back_3yrs coup nelda_election wdi_population_ln_avg3 wdi_gdppc_ln_avg3 wdi_gdp_const_ln_avg3 ///
   wdi_trade_avg3 wdi_aid_pc_ln_avg3 ulfelder_gatt_lag ///
   available_back_3yrs_ln i.year if agreement_back_3yrs >0, robust cluster(ccode_cow) fe 
     
* backsliding and breakdown   
eststo: xtreg agreement_backbreak_3yrs coup nelda_election wdi_population_ln_avg3 wdi_gdppc_ln_avg3 wdi_gdp_const_ln_avg3 ///
   wdi_trade_avg3 wdi_aid_pc_ln_avg3 ulfelder_gatt_lag ///
   available_backbreak_3yrs_ln i.year if agreement_backbreak_3yrs >0, robust cluster(ccode_cow) fe 

* transition
eststo: xtreg agreement_trans_3yrs coup nelda_election wdi_population_ln_avg3 wdi_gdppc_ln_avg3 wdi_gdp_const_ln_avg3 ///
   wdi_trade_avg3 wdi_aid_pc_ln_avg3 ulfelder_gatt_lag ///
   available_trans_3yrs_ln i.year if agreement_trans_3yrs >0, robust cluster(ccode_cow) fe
   
* liberalization  
eststo: xtreg agreement_lib_3yrs coup nelda_election wdi_population_ln_avg3 wdi_gdppc_ln_avg3 wdi_gdp_const_ln_avg3 ///
   wdi_trade_avg3 wdi_aid_pc_ln_avg3 ulfelder_gatt_lag ///
   available_lib_3yrs_ln i.year if agreement_lib_3yrs >0, robust cluster(ccode_cow) fe
     
* liberalization and transition   
eststo: xtreg agreement_libtrans_3yrs coup nelda_election wdi_population_ln_avg3 wdi_gdppc_ln_avg3 wdi_gdp_const_ln_avg3 ///
   wdi_trade_avg3 wdi_aid_pc_ln_avg3 ulfelder_gatt_lag ///
   available_libtrans_3yrs_ln i.year if agreement_libtrans_3yrs >0, robust cluster(ccode_cow) fe

* output
esttab, star(* 0.10 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(2))) stats(N r2_a, fmt(0 3) label("N" "Adj. R2")) legend label ///
   keep(coup nelda_election wdi_population_ln_avg3 wdi_gdppc_ln_avg3 wdi_gdp_const_ln_avg3 ///
   wdi_trade_avg3 wdi_aid_pc_ln_avg3 ulfelder_gatt_lag available_break_3yrs_ln available_back_3yrs_ln available_backbreak_3yrs_ln available_trans_3yrs_ln available_lib_3yrs_ln available_libtrans_3yrs_ln)
      

	  

******************************************************************************************
**********************5. Save dataset for robustness checks*******************************
******************************************************************************************

*** restrict set of variables included
keep ccode_cow year democracy* liberal* backslide* breakdown* transition* p_polity2_lag fh_score_lag ///
   vdem_v2x_polyarchy_lag liedlexical_index htw_ifhpol_lag

*** save
saveold LuedersLust2017_regimechangedata.dta, replace version(12)

